//
//  HJChatMessageSystemCell.m
//  XWC
//
//  Created by Hello on 2022/11/3.
//

#import "HJChatMessageSystemCell.h"
#import "HJChatMessageSystemLayout.h"
#import "HJChatMessageModel.h"
 
@interface HJChatMessageSystemCell()

@property (nonatomic, strong) HJChatMessageSystemLayout *systemLayout;
@property (nonatomic, weak) UILabel *contentLabel;
@property (nonatomic, weak) UIView *contentBackgroundView;

@end


@implementation HJChatMessageSystemCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
                
        
        UIView *contentBackgroundView = [UIView addToView:self.contentView];
        contentBackgroundView.backgroundColor = UIColorMake(0xEEEEEE);
        _contentBackgroundView = contentBackgroundView;
        contentBackgroundView.addCornerRadius(6);


        UILabel *contentLabel = [UILabel lableWithSuperView:contentBackgroundView font:UIFontMake(12) color:UIColor.tj_BEBDCAColor title:nil textAlignment:NSTextAlignmentCenter];
        contentLabel.numberOfLines = 0;
        
        _contentLabel = contentLabel;
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    
    _contentBackgroundView.frame = self.systemLayout.contentRect;
    _contentLabel.frame = self.systemLayout.textRect;
}

- (void)setMessageLayout:(HJChatMessageLayout *)messageLayout {
    [super setMessageLayout:messageLayout];
    
    self.systemLayout = (HJChatMessageSystemLayout *)messageLayout;
    self.contentLabel.text = messageLayout.messageModel.content;
    self.contentLabel.font = self.systemLayout.font;

}

@end

